package com.wz.jiangsu.wangteng;

import org.apache.kafka.clients.consumer.Consumer;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.kafka.listener.ConsumerAwareListenerErrorHandler;
import org.springframework.kafka.listener.ListenerExecutionFailedException;
import org.springframework.messaging.Message;

/**
 * @author zhrj
 */
@SpringBootApplication
@MapperScan("com.wz.jiangsu.wangteng.mapper")
public class PagedQueryApplication {
    public static void main(String[] args) {
        SpringApplication.run(PagedQueryApplication.class, args);
    }

    //异常处理器
    @Bean
    public ConsumerAwareListenerErrorHandler consumerAwareErrorHandler() {
        return new ConsumerAwareListenerErrorHandler() {
            @Override
            public Object handleError(Message<?> message, ListenerExecutionFailedException exception, Consumer<?, ?> consumer) {
                System.out.println("消费异常：" + message.getPayload());
                return null;
            }
        };
    }

}
